package com.zy.activity

import com.zy.activity.adapter.BaseActivityAdapter.ClickCallBack
import android.os.Bundle
import androidx.recyclerview.widget.RecyclerView
import com.zy.activity.bean.BaseMenuBean
import androidx.recyclerview.widget.LinearLayoutManager
import com.zy.activity.adapter.BaseActivityAdapter
import java.util.ArrayList

abstract class BaseMenuActivity : BaseActivity(), ClickCallBack {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_base_menu)
        val recyclerView = findViewById<RecyclerView>(R.id.base_menu_rv)
        val list: ArrayList<BaseMenuBean> = ArrayList()
        init(list)
        val adapter = BaseActivityAdapter(list)
        adapter.setClickCallBack(this)
        recyclerView.adapter = adapter
        recyclerView.layoutManager =
            LinearLayoutManager(baseContext, LinearLayoutManager.VERTICAL, false)
    }

    override fun click(bean: BaseMenuBean) {
        clickItem(bean)
    }

    protected abstract fun init(list: ArrayList<BaseMenuBean>)
    protected abstract fun clickItem(bean: BaseMenuBean)
}